home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc302emb.zip / LIBCF / STRING3.ASM < prev    next >
Assembly Source File  |  1994-03-18  |  448b  |  21 lines

  1. *
  2. * Compare two strings: strcmp(string1, string2)
  3. *
  4. strcmp    LDI    4,S        Get string1 pointer
  5. ?1    LDB    I        Get character
  6.     LDI    2,S        Get string2 pointer
  7.     CMPB    I        Compare
  8.     SJZ    ?2        Not same
  9.     LDB    I        Get char back
  10.     SJZ    ?3        Zero, strings match
  11.     LEAI    1,I        Advance string2
  12.     STI    2,S        Resave
  13.     LDI    4,S        Get pointer back
  14.     LEAI    1,I        Advance
  15.     STI    4,S        Resave
  16.     SJMP    ?1        And proceed
  17. ?2    GT            Is string1 < string2
  18.     JNZ    ?3        Yes, its OK
  19.     COM            Get -1
  20. ?3    RET
  21.